#pragma once

#include "CMILMatrix.h"
#include "CMILMatrix4x4.h"





class HWClip
{
public: 
	HWClip();
private: 
	HWClip(const HWClip & other);
	HWClip & operator=(const HWClip & other);
	void TransformPointsHelper(const CMILMatrix * pTransform);
public: 
	~HWClip();
	XBOOL Equals(const HWClip & other);
	HRESULT Set(const HWClip * pClip);
	void Set(const struct XRECTF_WH * pClip);
	void Reset();
	HRESULT Transform(xshared_ptr<CMILMatrix4x4 const > pTransform);
	HRESULT Transform(const CMILMatrix * pTransform);
	HRESULT Intersect(const struct XRECTF_WH * clip);
	HRESULT Intersect(const HWClip * clip);
	XBOOL DoesIntersect(const struct XRECTF_WH & clip);
	void GetBounds(struct XRECTF_WH * pBounds);
	XBOOL IsRectilinear();
	XBOOL IsClipAxisAlignedWith(const CMILMatrix * pWorldTransform);
	XBOOL Contains(const struct XPOINTF *);
	XBOOL DoesEntirelyContain(const struct XRECTF_WH * pOther);
	XBOOL DoesEntirelyContain(const HWClip * pOther);
	XBOOL IsEmpty();
	XBOOL IsInfinite();
	void GetRectangularClip(struct XRECTF_WH * pRect);
	HRESULT GetRectilinearClip(struct XRECTF_WH * pRect, const CMILMatrix * pTransform);
	void GetPolygonClip(struct XPOINTF * *, unsigned int *);
	HRESULT ApplyTransformAndClip(const xshared_ptr<CMILMatrix4x4 const > p3DProjection, const CMILMatrix * p2DTransform, const HWClip * p2DClip, XBOOL * pWasClipped);
private: 
	struct XRECTF_WH m_clip;


private: 
	struct XPOINTF * m_pPoints;
	XUINT32 m_cPoints;
	CMILMatrix m_transform; 

	XBOOL m_fIsEmpty:1; 
	XBOOL m_fIsInfinite:1;
	XBOOL m_fIsRectangular:1;

};

